package com.easypan.utils;

import com.easypan.entity.enums.VerifyRegexEnum;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class VerifyUtils {
    /**
     * 校验参数与规则是否匹配
     * @param regs 规则
     * @param value 匹配的值
     * @return 规则与value匹配：true
     */
    public static Boolean verify(String regs, String value) {
        if (StringTools.isEmpty(value)) {
            return false;
        }
        Pattern pattern = Pattern.compile(regs);
        Matcher matcher = pattern.matcher(value);
        return matcher.matches();
    }
    public static Boolean verify(VerifyRegexEnum regs, String values) {
        return verify(regs.getRegex(), values);
    }

}
